#include <iostream>
#include <map>
using namespace std;

int main_43()
{
    map<int,int> cnt;
    multimap<int,int,greater<int>> cnt_out;
    int n,num;
    cin>>n;
    for (int i=0; i<n ; i++ )
    {
        cin>>num;
        cnt[num]++;
    }
    for (map<int,int>::iterator it=cnt.begin(); it!=cnt.end() ; it++ )
    {
        cnt_out.insert(make_pair(it->second,it->first));
    }
    multimap<int,int,greater<int>>::const_iterator it;
    for (it=cnt_out.begin(); it!=cnt_out.end() ; it++ )
    {
        cout << it->second<<" "<<it->first << endl;
    }
    return 0;
}
